#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main() {
	int n, a, b, c, d, e, f;
	scanf("%d", &n);
	a = n / 1000;
	b = n / 100 - (a * 10);
	c = n / 10 - (a * 100) - (b * 10);
	d = n - (a * 1000) - (b * 100) - (c * 10);
	e = a;
	a = d;
	d = e;
	f = b;
	b = c;
	c = f;

	printf("%d%d%d%d\n", a, b, c, d);
	return 0;
}